package com.myinternet.lutu.config;

import com.myinternet.lutu.config.interceptor.OneInterceptor;
import com.myinternet.lutu.config.interceptor.TwoInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;


/**
 * @Configuration 代表示是一个配置类
 */

@Configuration
public class WebMvcConfigurer extends WebMvcConfigurationSupport {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {

		/**
		 * 拦截器按照顺序执行，需要添加拦截的适配器
		 * addPathPatterns() 参数为拦截的url
		 */
		registry.addInterceptor(new TwoInterceptor()).addPathPatterns("/*/**")
													 .addPathPatterns("/*/**");
		registry.addInterceptor(new OneInterceptor()).addPathPatterns("/*/**");
		
		super.addInterceptors(registry);
	}

}
